import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AccountVO, AccountForm, AccountQuery } from '@/api/system/account/types';

/**
 * 查询微信公众平台列表
 * @param query
 * @returns {*}
 */

export const listAccount = (query?: AccountQuery): AxiosPromise<AccountVO[]> => {
  return request({
    url: '/system/account/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询微信公众平台详细
 * @param id
 */
export const getAccount = (id: string | number): AxiosPromise<AccountVO> => {
  return request({
    url: '/system/account/' + id,
    method: 'get'
  });
};

/**
 * 新增微信公众平台
 * @param data
 */
export const addAccount = (data: AccountForm) => {
  return request({
    url: '/system/account',
    method: 'post',
    data: data
  });
};

/**
 * 修改微信公众平台
 * @param data
 */
export const updateAccount = (data: AccountForm) => {
  return request({
    url: '/system/account',
    method: 'put',
    data: data
  });
};

/**
 * 删除微信公众平台
 * @param id
 */
export const delAccount = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/account/' + id,
    method: 'delete'
  });
};

export const getAuth = () => {
  return request({
    url: '/system/wx/authorize/get',
    method: 'get'
  });
}